package com.example.demo.controller;

import com.example.demo.config.YamlPathConfig;
import com.example.demo.util.YamlUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yaml.snakeyaml.Yaml;

@RestController
@CrossOrigin
@RequestMapping("/yaml")
public class YamlController {
    @Autowired
    private YamlPathConfig yamlPathConfig;

    @GetMapping("/load")
    public void Load() {
        YamlUtil.read(yamlPathConfig.getReadFilePath());
    }

    @GetMapping("store")
    public void store() {
        YamlUtil.write(yamlPathConfig.getWriteFilePath());
    }
}
